package com.huage_10.lesson_02;

import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

public class ReflectTest02 {
    public static void main(String[] args) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        //加载配置文件
        Properties prop = new Properties();
        FileReader fr = new FileReader("class1\\src\\com\\huage_10\\lesson_02\\class.txt");

        prop.load(fr);
        fr.close();

        String ClassName =  prop.getProperty("ClassName");
        String MethodName =  prop.getProperty("MethodName");

        Class<?> c = Class.forName(ClassName);
        Object obj = c.newInstance();
        Method method = c.getMethod(MethodName);
        method.invoke(obj);
    }
}
